/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/
#pragma once

#include "kbase.h"
#include "kstream.h"
#include "kstructdata.h"
#include "kencoding.h"

class kTextWriter : public kBase {
private:
	kStream* _stream;

public:
	inline kTextWriter(kStream* stream) {
		_stream = stream;
	}
	~kTextWriter() {
	}
	inline size_t write(tchar c) {
		return _stream->write(kDataView((uint8_t*)&c, sizeof(c)));
	}
	inline size_t writeLn() {
		return write(_T('\n'));
	}
	inline size_t write(const std::tstring& str) {
		return _stream->write(kStructDataView(str));
	}
	inline size_t writeLn(const std::tstring& str) {
		size_t s = write(str);
		return s + writeLn();
	}
};
